unit untEditorSheet;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, ComCtrls, frmEditor;

type

{ TEditorTabSheet }

TEditorTabSheet = class(TTabSheet)
    FEditor: TEditorFrame;
  private
    procedure CaptionChanged(const ANewCaption: String);
  public
    constructor Create(TheOwner: TComponent); override;
    destructor Destroy; override;

    property Editor: TEditorFrame read FEditor;
end;

implementation

uses Controls; // For Align = alClient

{ TEditorTabSheet }

constructor TEditorTabSheet.Create(TheOwner: TComponent);
begin
  inherited Create(TheOwner);
  FEditor := TEditorFrame.Create(Self);
  FEditor.Align := alClient;
  FEditor.OnChangeCaption := @CaptionChanged;
  InsertControl(FEditor);
  // When there were no pages before, FEditor will be drawn on top of the tabs
  if TPageControl(TheOwner).PageCount = 0 then
     TPageControl(TheOwner).InvalidateClientRectCache(False);
end;

destructor TEditorTabSheet.Destroy;
begin
  if Assigned(FEditor) then FEditor.Free;
  inherited Destroy;
end;

procedure TEditorTabSheet.CaptionChanged(const ANewCaption: String);
begin
  Self.Caption := ANewCaption;
end;

end.

